package c.e.b.h.e.k;

import android.util.Log;
import c.e.b.h.e.b;
import c.e.b.h.e.s.e;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.concurrent.atomic.AtomicBoolean;

/* compiled from: CrashlyticsUncaughtExceptionHandler */
public class k0 implements UncaughtExceptionHandler {
    public final a a;
    public final e b;
    public final UncaughtExceptionHandler c;
    public final AtomicBoolean d = new AtomicBoolean(false);

    /* compiled from: CrashlyticsUncaughtExceptionHandler */
    public interface a {
    }

    public k0(a aVar, e eVar, UncaughtExceptionHandler uncaughtExceptionHandler) {
        this.a = aVar;
        this.b = eVar;
        this.c = uncaughtExceptionHandler;
    }

    public void uncaughtException(Thread thread, Throwable th) {
        b bVar = b.a;
        this.d.set(true);
        String str = "Crashlytics completed exception processing. Invoking default exception handler.";
        if (thread == null) {
            try {
                bVar.d("Could not handle uncaught exception; null thread");
            } catch (Exception e) {
                String str2 = "An error occurred in the uncaught exception handler";
                if (bVar.a(6)) {
                    Log.e("FirebaseCrashlytics", str2, e);
                }
            } catch (Throwable th2) {
                bVar.b(str);
                this.c.uncaughtException(thread, th);
                this.d.set(false);
            }
        } else if (th == null) {
            bVar.d("Could not handle uncaught exception; null throwable");
        } else {
            ((w) this.a).a(this.b, thread, th);
        }
        bVar.b(str);
        this.c.uncaughtException(thread, th);
        this.d.set(false);
    }
}
